package com.yxy.utils;

import com.yxy.base.RestResponse;
import com.yxy.feign.AuthService;
import com.yxy.feign.DTO.GetParamValueQueryDTO;
import com.yxy.feign.authModel.AppDataDicDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author yuxiaoyang
 * @date 2020-12-03
 * app字典服务 帮助类
 */
@Service
public class DataDicHelper {
  @Value("${spring.application.name}")
  private String appCode;//从配置文件中读取 项目的appCode

  @Autowired
  private TokenCheckUtil tokenCheckUtil;

  @Autowired
  private AuthService authService;

  /**
   * 根据字典具体项的value查询具体项的信息
   * @param dicDetailValue 格式: DIC_GENDER.男
   * @return AppDataDicDetail
   */
  public AppDataDicDetail getDataDicDetailByValue(String dicDetailValue) {
    String invokeUnionAuthToken = tokenCheckUtil.getInvokeUnionAuthToken();
    RestResponse<AppDataDicDetail> restResponse = authService.getDataDicDetailByValue(appCode, dicDetailValue,invokeUnionAuthToken);
    return restResponse.getContent();
  }

  /**
   * 根据字典具体项的id查询具体项的信息
   * @param id
   * @return AppDataDicDetail
   */
  public AppDataDicDetail getDataDicDetailById(long id) {
    String invokeUnionAuthToken = tokenCheckUtil.getInvokeUnionAuthToken();
    RestResponse<AppDataDicDetail> restResponse = authService.getDataDicDetailById(id, invokeUnionAuthToken);
    return restResponse.getContent();
  }
}
